package com.slb.slnwp.common.utils.page;

import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author joinly
 * @date 2020-06-22 15:45
 * @desc: Controller基类
 */
public class InspectBaseController {
    //将查询条件转换为map集合
    public static Map<String, Object> InfoToMap(Info info) {
        Map<String, Object> params = new HashMap<>();
        // 封装查询条件
        for (Condition con : info.getConditions()) {
            String name = con.getName();
            String value = con.getValue();
            if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) {
                String tmp = StringUtils.trim(con.getValue());
                tmp = tmp.replaceAll("%", "\\\\%");
                params.put(name, tmp);
            }
        }
        return params;
    }
}
